package com.file.manage.infrastructure.dao.impl;


import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.file.manage.domain.entity.OperationLogs;
import com.file.manage.domain.entity.UserFileMapping;
import com.file.manage.domain.param.OperationLogsQueryParam;
import com.file.manage.infrastructure.base.dao.impl.BaseDaoImpl;
import com.file.manage.infrastructure.dao.OperationLogsDao;
import com.file.manage.infrastructure.dao.UserFileMappingDao;
import com.file.manage.infrastructure.mapper.OperationLogsMapper;
import com.file.manage.infrastructure.mapper.UserFileMappingMapper;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author H41
 * @Type IOperationLogsDaoImpl.java
 * @date 2025/5/31 12:26
 * @Desc
 */
@Repository
public class UserFileMappingImpl extends BaseDaoImpl<UserFileMappingMapper, UserFileMapping> implements UserFileMappingDao {
    @Override
    public void deleteByFileId(String fileId) {
        LambdaQueryWrapper<UserFileMapping> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UserFileMapping::getFileId, fileId);
        this.remove(wrapper);
    }

    @Override
    public void deleteByUserId(String userId) {
        LambdaQueryWrapper<UserFileMapping> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UserFileMapping::getUserId, userId);
        this.remove(wrapper);
    }

    @Override
    public List<UserFileMapping> selectByUserId(String userId) {
        LambdaQueryWrapper<UserFileMapping> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UserFileMapping::getUserId, userId);
        return this.list(wrapper);
    }

    @Override
    public List<UserFileMapping> selectByFileId(String fileId) {
        LambdaQueryWrapper<UserFileMapping> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UserFileMapping::getFileId, fileId);
        return this.list(wrapper);
    }

}
